package com.quick.controller;

import com.quick.service.JobService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName JobController
 * @Description TODO
 * @Author wangxin332
 * @Date 2018/10/19 下午12:42
 * @Version 1.0
 **/
@RestController
@RequestMapping("/job")
public class JobController {
	@Resource
	private JobService jobService;

	/**
	 * 暂停
	 * adSubDayReportWorkerScheduler
	 * adSubDayReportMultithreadingWorkerScheduler
	 * @param jobName
	 * @return
	 */
	@GetMapping("/pauseJob")
	public String pauseJob(String jobName){
		jobService.pauseJob(jobName);
		return "success";
	}

	/**
	 * 启动
	 * adSubDayReportWorkerScheduler
	 * adSubDayReportMultithreadingWorkerScheduler
	 * @param jobName
	 * @return
	 */
	@GetMapping("/startJob")
	public String startJob(String jobName){
		jobService.startJob(jobName);
		return "success";
	}

	/**
	 * 是否启动
	 * adSubDayReportWorkerScheduler
	 * adSubDayReportMultithreadingWorkerScheduler
	 * @param jobName
	 * @return
	 */
	@GetMapping("/isStarted")
	public boolean isStarted(String jobName){
		return jobService.isStarted(jobName);
	}

	/**
	 * 获取所有的job状态
	 * @return
	 */
	@GetMapping("/getJob")
	public List<Map> getJob(){
		return jobService.getJob();
	}
}

